package com.lsq.springboot;

import com.lsq.spring.LsqApplicationContext;

/**
 * @author lsq
 * @description TODO
 * @date 2023/9/7
 */
public class LsqSpringApplication {
    public static void run(Class<?> source) {
        //启动spring容器
        LsqApplicationContext lsqApplicationContext = new LsqApplicationContext(source);


        //启动并判断tomcat、jetty
        WebServer webServer = getWebserver(lsqApplicationContext);
        webServer.start();
        //startTomcat(lsqApplicationContext);
    }

    private static WebServer getWebserver(LsqApplicationContext lsqApplicationContext) {
        WebServer webServer = (WebServer) lsqApplicationContext.getBean(String.valueOf(WebServer.class));
        if (webServer == null){
            throw new NullPointerException();
        }

        //启动并判断tomcat、jetty
        return webServer;
    }

    private static void startTomcat(LsqApplicationContext lsqApplicationContext) {
        //启动tomcat

        //添加dispatcherservlet寻找匹配接口,需要传入spring容器applicationcontext
    }
}
